﻿using System;
using System.Collections.Generic;

using ZoeEngine.Framework;
using ZoeEngine.Services.Physics;

using FarseerPhysics.Dynamics.Joints;
using FarseerPhysics.Factories;

namespace ZoeEngine.Components.Physics
{
    public class PhysFixedAngleJoint : EntityComponent
    {
        private PhysicsProvider _physicsProvider;
        private FixedAngleJoint _joint;

        private PhysBodyComponent _attachment;
        private PhysBodyComponent _physBody;

        public override void Initialize()
        {
            base.Initialize();
        }
        public override void Start()
        {
            base.Start();

            _physBody = this.Owner.Find<PhysBodyComponent>();

            _physicsProvider = Zoe.GetService<IPhysicsService>() as PhysicsProvider;
            if (_physicsProvider == null)
            {
                throw new ArgumentException("Could not locate appropriate service or provider is of incorrect type.");
            }

            _joint = JointFactory.CreateFixedAngleJoint(_physicsProvider.World, _physBody.Body);
        }
    }
}
